/*
 * BaseController.java
 *
 * Copyright 2012 the original author or authors(ninglong).
 *
 * Licensed under the org.geek.common.base, Version 1.0 (the "License");
 *
 */
package org.geek.common.base;

import javax.servlet.http.HttpServletRequest;

import org.geek.common.util.DateUtil;
import org.geek.domain.User;
import org.slf4j.Logger;
import org.springframework.ui.ModelMap;

/**
 * <p></p>
 * @author ninglong bhd2973@qq.com
 * @version V1.0
 */
public abstract class BaseController {
	
	/**
	 * 初始化页面
	 * @param model
	 * @return
	 */
	public abstract String initPage(HttpServletRequest request,ModelMap model);
	
	/**
	 * @param request
	 * @return 当前登录用户
	 */
	public User getUser(HttpServletRequest request){
		return (User)request.getSession().getAttribute(AppConstants.LOGINUSER);
	}
	
	/**
	 * 功能访问日志
	 * @param request
	 * @return
	 */
	protected void log(HttpServletRequest request,Logger logger,String msg){
		logger.debug(this.getUser(request).getAccount()+"于"+DateUtil.getNow(DateUtil.FORMAT_FULL_CN)+msg);
	}
}
